package com.avertymaroc.beans;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import android.widget.TextView;

public class PercentBar extends TextView {

	private int mColor =Color.parseColor("#3C3C3C");
	private Paint mPaint;
	private Double  percent = 53.6;

	public PercentBar(Context context) {
		super(context);
		init(context);
	}
	public PercentBar(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}
	
	public PercentBar(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}
	
	public void init(Context context){
		mPaint = new Paint();
		//Shader gradient = new SweepGradient (getWidth() / 4,getHeight()/4, Color.parseColor("#ffa40c"), Color.parseColor("#ffca35"));
		//mPaint.setShader(gradient);
		mPaint.setColor(this.mColor);
	
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		
		
		RectF rect = new RectF(1, 0, (float)(percent * getWidth() /100), getHeight() );

		canvas.drawRect(rect, mPaint);
		
		super.onDraw(canvas);
		
	}
	
	
	public Double getPercent() {
		return percent;
	}
	public void setPercent(Double percent) {
		this.percent = percent;
	}


}
